﻿

using System;
using System.ServiceModel;
using WCFContract.Contract.StudentContract;



namespace WCFService
{
    /// <summary>
    /// 学生会话服务
    /// </summary>
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
    public class StudentServicePerSession : IStudent, IDisposable
    {
        private Guid gid;
        private DateTime dt ;

        public StudentServicePerSession()
        {
            dt = DateTime.Now;
            gid = Guid.NewGuid();
            Console.WriteLine("StudentServicePerSession Init " + gid.ToString() + " at " + dt.ToString());
        }

        public string GetStudentName(int id)
        {
            Console.WriteLine("StudentServicePerSession Call " + gid.ToString() + " at " + DateTime.Now.ToString());
            return id + "_" + dt.ToString();
        }

        public void Dispose()
        {
            Console.WriteLine("StudentServicePerSession Dispose " + gid.ToString() + " at " + DateTime.Now.ToString());
        }
    }
}
